package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.constant.XbbConstant;
import com.xbongbong.paas.enums.clazz.FieldTypeClassifyClass;
import com.xbongbong.saas.constant.BasicConstant;
import lombok.Getter;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 字段类型枚举类
 *
 * @author wufeng
 * @date 2018/8/10 9:54
 */
@Getter
public enum FieldTypeEnum {
    /**
     *  
     */
    ID(13,"id",BelongEnum.SYSTEM.getAlias(),"id","num",1,EsAliasEnum.TEXT.getMax()),
    //id,
    DATAID(0,"dataId",BelongEnum.SYSTEM.getAlias(),"所选数据","num",1,EsAliasEnum.TEXT.getMax()),
    //formId
    FORM_ID(0,"formId",BelongEnum.SYSTEM.getAlias(),"表单id","num",1,EsAliasEnum.TEXT.getMax()),
    // 单行文本
    TEXT(1, "text", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.text", "text", 1, EsAliasEnum.TEXT.getMax()),
    //数字
    NUM(2, "num", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.num", "num", 1,  EsAliasEnum.NUM.getMax()),
    // 长整形留作业务使用
    LONG(5, "long", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.num", "long", 1,  EsAliasEnum.LONG.getMax()),
    // 长整形留作业务使用 -- 与data平级的系统级别预留字段，非自定义字段，对应SysAliasEnum枚举内占位的字段类型
    SYS_LONG(50, "long", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.num", "long", 1,  SysAliasEnum.sysLong.getMax()),
    // 下拉框:combo
    COMBO(3, "combo", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.combo", "text", 1, EsAliasEnum.TEXT.getMax()),
    //逻辑下拉（如客户是否归档）
    COMBO_NUM(19, "combo_num", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.combo_num", "num", 1, EsAliasEnum.NUM.getMax()),
    // DateTimeEnum
    DATETIME(4, "datetime", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.datetime", "date", 1, EsAliasEnum.DATE.getMax()),
    // 图片image
    IMAGE(6, "image", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.image", "file", 1, EsAliasEnum.FILE.getMax()),
    // 多行文本
    TEXTAREA(7, "textarea", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.textarea", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 附件 upload
    UPLOAD(8, "upload", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.upload", "file", 1, EsAliasEnum.FILE.getMax()),
    // 复选框组：checkboxgroup
    CHECKBOX_GROUP(9, "checkbox_group", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.checkbox_group", "array", 1, EsAliasEnum.ARRAY.getMax()),
    //星级
    STAR(10, "star", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.star", "num", 1, EsAliasEnum.NUM.getMax()),
    // address 地址
    ADDRESS(12, "address", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.address", "address", 1, EsAliasEnum.ADDRESS.getMax()),
    // 音频
    VIDEO(14, "video", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.video", "file", 1, EsAliasEnum.FILE.getMax()),
    //开关
    SWITCH(15, "switch", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.switch", "num", 1, EsAliasEnum.NUM.getMax()),
    // 员工选择
    SELECT_DEPARTMENT(16, "select_department", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.select_department", "text", 1, EsAliasEnum.TEXT.getMax()),
    //flowStatus
    FLOW_STATUS(17,"flowStatus",BelongEnum.SYSTEM.getAlias(),"flowStatus","num",1,1),
    //计数（用于统计）
    COUNT(18,"count",BelongEnum.BASIC.getAlias(), "enum.fieldType.description.count","num",1,1),
    //计算字段（用于统计）
    COMPUTED_FIELD(20,"computed_field",BelongEnum.BASIC.getAlias(), "enum.fieldType.description.computed_field","num",1,3),
    //生日
    BIRTHDAY(37, "birthday", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.birthday", "text", 1, EsAliasEnum.TEXT.getMax()),
    // radiogroup 单选按钮
    RADIO_GROUP(10000, "radio_group", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.radio_group", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 下拉框复选：combocheck
    COMBO_CHECK(10001, "combo_check", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.combo_check", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 分割线：separator
    SEPARATOR(10002, "separator", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.separator", "other", 1, EsAliasEnum.OTHER.getMax()),
    // location定位
    LOCATION(10003, "location", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.location", "geo", 1, EsAliasEnum.GEO.getMax()),
    // 描述文本
    MEMO(10004, "memo", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.memo", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 超链接
    HREF(10005, "href", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.href", "file", 1, EsAliasEnum.FILE.getMax()),
    // 子表单 subform
    SUB_FORM(10006, "sub_form", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.sub_form", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    // 关联查询 linkquery
    LINK_QUERY(10007, "link_query", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.link_query", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 关联数据 linkdata
    LINK_DATA(10008, "link_data", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.link_data", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 成员单选 user
    USER(10009, "user", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.user", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 成员多选 usergroup
    USER_GROUP(10010, "user_group", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.user_group", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // dept 部门单选
    DEPT(10011, "dept", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.dept", "text", 1, EsAliasEnum.TEXT.getMax()),
    // deptgroup 部门多选
    DEPT_GROUP(10012, "dept_group", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.dept_group", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 创建人
    CREATORID(10013, "creatorId", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.creatorid", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 创建时间
    ADDTIME(10014, "addTime", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.addtime", "date", 1, EsAliasEnum.DATE.getMax()),
    // 修改时间
    UPDATETIME(10015, "updateTime", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.updatetime", "date", 1, EsAliasEnum.DATE.getMax()),
    // 所属部门
    DEPARTMENTID(10016, "departmentId", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.departmentid", "num", 1, EsAliasEnum.NUM.getMax()),
    // 拥有者
    OWNERID(10017, "ownerId", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.ownerid", "text", 1, EsAliasEnum.TEXT.getMax()),
    // Synergetic协同人
    COUSERID(10018, "coUserId", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.couserid", "text", 1, EsAliasEnum.TEXT.getMax()),
    // serial number 流水号
    SERIALNO(10019, "serialNo", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.serialno", "text", 1, EsAliasEnum.TEXT.getMax()),
    //仓库
    WAREHOUSE_ID(10020, "warehouseId", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.warehouse_id","num",1,EsAliasEnum.NUM.getMax()),
    //预警类型
    WARINING_TYPE(10021, "wariningType", BelongEnum.STOCK.getAlias(), "enum.fieldType.description.warining_type","num",1,EsAliasEnum.NUM.getMax()),
    //保质状况
    GUARANTEE_STATUS(10022, "guaranteeStatus", BelongEnum.STOCK.getAlias(), "enum.fieldType.description.guarantee_status","num",1,EsAliasEnum.NUM.getMax()),
    /**
     * 分类id 库存查询也用到了这个
     * @see com.xbongbong.saas.enums.StockSearchConditionEnum
     */
    CATEGORY_ID(10023, "category_id", BelongEnum.SAAS.getAlias(),"enum.fieldType.description.category_id","num",1,EsAliasEnum.NUM.getMax()),

    TEAM_USER(10024, "teamUser", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.team_user","text",1,EsAliasEnum.TEXT.getMax()),

    TEAM_USER_TYPE(10025, "type", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.team_user_type","text",1,EsAliasEnum.TEXT.getMax()),
    // 完成时间
    ENDTIME(10026, "endTime", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.endtime", "date", 1, EsAliasEnum.DATE.getMax()),
    // 关闭时间
    CLOSETIME(10027, "closeTime", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.closetime", "date", 1, EsAliasEnum.DATE.getMax()),
    //抄送人
    COPY_USER(10028, "copyUser", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.copy_user", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 其他费用
    SURCHARGE(10029, "surcharge", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.surcharge", "num", 1, EsAliasEnum.NUM.getMax()),
    //阶段推进器字段
    STAGE_THRUSTER(10030, "stage_thruster", BelongEnum.ULTIMATE.getAlias(), "enum.fieldType.description.stage_thruster", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 关联数据多选
    LINK_DATA_MULTI(10032, "link_data_multi", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.link_data_multi", "array", 1, EsAliasEnum.ARRAY.getMax()),
    //手签
    MANUAL_SIGN(10033, "manual_sign", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.manual_sign", "file", 1, EsAliasEnum.FILE.getMax()),
    //富文本
    RICH_TEXT(10034, "rich_text", BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.rich_text", "richText", 1, 1),
    // 模板字段 在线编辑
    TEMPLATE_FIELD(10035, "template_field", BelongEnum.BASIC.getAlias(), "enum.fieldType.description.template_field", "text", 1, 1),

    // =========================Saas特有控件==============================
    // 关联业务单选，比如选择关联客户（关联ID）
    LINK_BUSINESS_SINGLE(20001, "link_business_single", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.link_business_single", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 关联业务多选，比如选择关联客户（多选）
    LINK_BUSINESS_MULTI(20002, "link_business_multi", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.link_business_multi", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 联系电话
    CONTACT_NUMBER(20003, "contact_number", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.contact_number", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    // 选择产品
    SELECT_PRODUCT(20004, "select_product", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.select_product", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 勾选+下拉选择，比如访客计划中的执行人（可以多选）
    CHECK_COMBO(20005, "check_combo", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.check_combo", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 下拉+关联业务选择，比如跟进记录的跟进业务
    COMBO_LINK_BUSINESS(20006, "combo_link_business", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.combo_link_business", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 开关+文本显示，比如今日计划
    SWITCH_TEXT(20007, "switch_text", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.switch_text", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    // 产品规格
    SPECIFICATION(20008, "specification", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.specification", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 产品库存
    PRODUCT_STOCK(20009, "product_stock", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.product_stock", "num", 1, EsAliasEnum.NUM.getMax()),
    // 文本后带勾选框
    TEXT_CHECK(20010, "text_check", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.text_check", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 富文本编辑器
    RICH_TEXT_EDITOR(20011, "rich_text_editor", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.rich_text_editor", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 关联业务+下拉，比如跟进记录的关联客户
    LINK_BUSINESS_COMBO(20012, "link_business_combo", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.link_business_combo", "text", 1, EsAliasEnum.TEXT.getMax()),
    // 关联新建
    LINK_FORM(20013, "link_form", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.link_form", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 孤独子表单
    SINGLE_SUB_FORM(20014, "single_sub_form", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.single_sub_form", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    // 工单超时
    WORK_ORDER_TIME_OUT(20015, "work_order_time_out", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.work_order_time_out", "text", 1, EsAliasEnum.TEXT.getMax()),
    WORK_ORDER_ROB(20016, "type", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_rob", "num", 1, EsAliasEnum.NUM.getMax()),
    //工单超时，么的办法了，曾经我也想做个好人
    WORK_ORDER_DATA_TIME_OUT(20017, "work_order_data_time_out", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_data_time_out", "text", 1, EsAliasEnum.TEXT.getMax()),
    WORK_ORDER_DATA_TIME_NOT_OUT(20018, "work_order_data_time_not_out", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_data_time_not_out", "text", 1, EsAliasEnum.TEXT.getMax()),
    //工单状态
    WORK_ORDER_STATUS(20021, "status", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_status", "num", 1, EsAliasEnum.NUM.getMax()),
    //工单阶段
    WORK_ORDER_STAGE(20022, "stage_id", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_stage", "num", 1, EsAliasEnum.NUM.getMax()),
    WORK_ORDER_ALL_OUTBOUND(20023, "allOutbound", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.work_order_all_outbound", "num", 1, EsAliasEnum.NUM.getMax()),
    //多模板选择模板字段
    TEMPLATE(20024, "template", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.template", "text", 1, EsAliasEnum.TEXT.getMax()),
    //工单阶段状态
    WORK_ORDER_NODE_STATUS(20025, "num_3", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.work_order_node_status", "num", 1, EsAliasEnum.NUM.getMax()),
    //最后跟进时间
//    LAST_CONNECT_TIME(20023, "last_connect_time", BelongEnum.SAAS.getAlias(), "最后跟进时间", "date", 1, 20),
    //跟进记录日志类型
    LOG_TYPE(20026, "logType", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.log_type", "num", 1, EsAliasEnum.NUM.getMax()),
    //工单阶段名称
    WORK_ORDER_STAGE_NAME(20027, "stageName", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.work_order_stage_name", "text", 1, EsAliasEnum.TEXT.getMax()),
    PRE_OWNER_ID(20028,"preOwnerId",BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.pre_owner_id","text",1,EsAliasEnum.TEXT.getMax()),
    // 公海分组-省特殊选择
    PUBLIC_GROUP_PROVINCE(20029, "public_group_province", "public_group_province","enum.fieldType.description.public_group_province", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 级联选择
    CASCADER(20030,"cascader",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.cascader", "array", 1, EsAliasEnum.ARRAY.getMax()),
    BATCH(20031,"batch",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.batch", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 选择采购合同
    SELECT_PURCHASE(20032, "select_purchase", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.select_purchase", "array", 1, EsAliasEnum.ARRAY.getMax()),

    // 选择合同
    SELECT_CONTRACT(20033, "select_contract", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.select_contract", "array", 1, EsAliasEnum.ARRAY.getMax()),
    // 选择服务项目
    SELECT_SERVICE(20034, "select_service", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.select_service", "array", 1, EsAliasEnum.ARRAY.getMax()),

    //saas列表操作filedType
    OPTION(30000,"option",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.option", "option", 1, 1),
    FOCUS(30001,"focus",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.focus", "option", 1, 1),
    REMIND(30002,"remind",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.remind", "option", 1, 1),
    CALL(30003,"call",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.call", "option", 1, 1),
    FLOW(30004,"flow",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.flow", "option", 1, 1),
    CONTRACT(30005,"contract",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.contract", "option", 1, 1),
    PRODUCT(30006,"product",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.product", "option", 1, 1),
    STOCK_SEARCH(30007, "stockSearch", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.stock_search", "option", 1, 1),
    WAIT_INSTOCK_CONTRACT(30008,"contract",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.wait_instock_contract", "option", 1, 1),
    WAIT_OUTSTOCK_PRODUCT(30009,"product",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.wait_outstock_product", "option", 1, 1),
    HEAD_RADIO_GROUP(30010,"headRadioGroup",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.head_radio_group", "option", 1, 1),
    HEAD_CHECKBOX_GROUP(30011,"headCheckboxGroup",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.head_checkbox_group", "option", 1, 1),
    WARNING_SEARCH(30012, "warningSearch", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.warning_search", "option", 1, 1),
    RANGE_SCREEN(30013,"rangeScreen",BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.range_screen", "rangeScreen", 1, 1),
    SEQ_TRACK(30014, "seqTrack", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.seq_track", "seqTrack", 1, 1),
    SEQ(30015, "seq", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.seq", "seq", 1, 1),

    //库存 新的层级，面子够大
    //仓库
    STOCK_WAREHOUSE_ID(40001, "warehouseId", BelongEnum.STOCK.getAlias(), "enum.fieldType.description.stock_warehouse_id","num",1,EsAliasEnum.NUM.getMax()),
    WAREHOUSE_CHECKED(40002, "warehouseChecked", BelongEnum.STOCK.getAlias(), "enum.fieldType.description.warehouse_checked","num",1,EsAliasEnum.NUM.getMax()),
    WAREHOUSE_IS_NOTIFY(40003, "isNotify", BelongEnum.STOCK.getAlias(), "enum.fieldType.description.warehouse_is_notify","num",1,EsAliasEnum.NUM.getMax()),
    ALL_WAREHOUSE_ALL_LIMIT(40004, "allWarehouseAllLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.all_warehouse_all_limit","num",1,EsAliasEnum.NUM.getMax()),
    ALL_WAREHOUSE_UPPER_LIMIT(40005, "allWarehouseUpperLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.all_warehouse_upper_limit","num",1,EsAliasEnum.NUM.getMax()),
    ALL_WAREHOUSE_LOWER_LIMIT(40006, "allWarehouseLowerLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.all_warehouse_lower_limit","num",1,EsAliasEnum.NUM.getMax()),
    CHECKED_WAREHOUSE_ALL_LIMIT(40007, "checkedWarehouseAllLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.checked_warehouse_all_limit","num",1,EsAliasEnum.NUM.getMax()),
    CHECKED_WAREHOUSE_UPPER_LIMIT(40008, "checkedWarehouseUpperLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.checked_warehouse_upper_limit","num",1,EsAliasEnum.NUM.getMax()),
    CHECKED_WAREHOUSE_LOWER_LIMIT(40009, "checkedWarehouseLowerLimit", BelongEnum.WARNING.getAlias(), "enum.fieldType.description.checked_warehouse_lower_limit","num",1,EsAliasEnum.NUM.getMax()),
    BATCH_WAREHOUSE_ID(40010,"warehouseId",BelongEnum.BATCH.getAlias(), "enum.fieldType.description.batch_warehouse_id","num",1,30),
    BATCH_WAREHOUSE_CHECKED(40011, "warehouseChecked", BelongEnum.BATCH.getAlias(), "enum.fieldType.description.batch_warehouse_checked","num",1,EsAliasEnum.NUM.getMax()),
    BATCH_PRODUCE_DATE(40012, "batchProduceDate", BelongEnum.BATCH.getAlias(), "enum.fieldType.description.batch_produce_date","num",1,EsAliasEnum.NUM.getMax()),
    BUSINESS_ID(40013, "businessId", BelongEnum.STOCK.getAlias(),"enum.fieldType.description.business_id","num",1,EsAliasEnum.NUM.getMax()),
    REF_ID(40014, "refId", BelongEnum.STOCK.getAlias(),"enum.fieldType.description.ref_id","num",1,EsAliasEnum.NUM.getMax()),
    STOCK_FLOW_SUB_FORM(40015, "stockFlowSubForm", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.stock_flow_sub_form", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    STOCK_FLOW_SHEET_DATE(40016, "stockFlowSheetDate", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.stock_flow_sheet_date", "date", 1, EsAliasEnum.DATE.getMax()),
    //业务类别筛选字段
    BUSINESS_TYPE(40017,"business_type",BelongEnum.BATCH.getAlias(), "enum.fieldType.description.business_type","num",1,EsAliasEnum.NUM.getMax()),

    // 流程用，我也不想加的
    CREATOR_DEPT(50001, "creator_dept", "creator_dept", "enum.fieldType.description.creator_dept","array",1,EsAliasEnum.ARRAY.getMax()),

    //回款单内新增的两个字段类型
    SHEET_ALONE(60001, BasicConstant.ALONE,BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.sheet_alone","num",1,3),
    SHEET_UUID(60002,BasicConstant.UUID,BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.sheet_uuid","text",1,EsAliasEnum.TEXT.getMax()),

    LINK_FORM_BUTTON(700001,"form",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.link_form_button","button",1,3),

    LABEL(800000,"label",BelongEnum.BASIC.getAlias(), "enum.fieldType.description.label","array",1,EsAliasEnum.ARRAY.getMax()),
    //评分区间筛选字段
    SCORE_RANGE(800010,"score_range",BelongEnum.COMPLEX.getAlias(), "enum.fieldType.description.score_range","num",1,EsAliasEnum.NUM.getMax()),


    //应收账期
    ACCOUNT_PERIOD(700002,"account_period",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.account_period","text",1,EsAliasEnum.TEXT.getMax()),
    //系统字段sys_long_10，生成规则 1:手动创建应收 2:按开票产生应收 3:按出库产生应收
    SYS_LONG_10(700003, "sysLong10", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.sys_long_10", "num", 1, EsAliasEnum.NUM.getMax()),

    SOURCE(800001, "source", BelongEnum.SAAS.getAlias(),"enum.fieldType.description.source","num",1,EsAliasEnum.NUM.getMax()),

    //营销适用地区
    APPLICATION_AREA(850000,"application_area",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.application_area","array",1,EsAliasEnum.ARRAY.getMax()),

    // 经销商
    /**
     * 所在地区
     */
    AREA(900001,"area",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.area","text",1,EsAliasEnum.TEXT.getMax()),
    /**
     * 可采购商品
     */
    PURCHASEABLE_GOODS(900002,"purchaseable_goods",BelongEnum.SAAS.getAlias(), "enum.fieldType.description.purchaseable_goods","array",1,EsAliasEnum.ARRAY.getMax()),
    /**
     * 订货单选择收货人
     */
    LINK_RECEIVER(900003, "link_receiver", BelongEnum.SAAS.getAlias(),"enum.fieldType.description.link_receiver","text",1,EsAliasEnum.TEXT.getMax()),

    /**
     * 对账日期
     */
    CHECK_DATE(900010, "check_date", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.check_date", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),

    /**
     * 阶段比例特殊类型
     */
    STAGE_RATIO(10031, "stage_ratio", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.stage_ratio", "long", 1, EsAliasEnum.LONG.getMax()),

    //成员、部门筛选范围字段,不进入ES,在表单设计中成员、部门相关字段设置自定义可选范围时用到
    USER_NAME(900050, "user_name", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.user_name", "array", 1, 1),
    DEPT_NAME(900051, "dept_name", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.dept_name", "array", 1, 1),
    ROLE_NAME(900052, "role_name", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.role_name", "array", 1, 1),
    REGISTER_USER(900053, "register_user", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.register_user", "text", 1, 1),
    REGISTER_DEPT(900054, "register_dept", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.register_dept", "array", 1, 1),


    /**
     * 待采购列表页以销定购明细 库存查询特殊字段
     */
    WAIT_PURCHASE_DETAIL(900020, "wait_purchase_detail", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.wait_purchase_detail", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),
    /**
     * 智能补货列表页建议采购量特殊字段
     */
    SMART_REPLENISHMENT_ADVISE(900021, "smart_replenishment_advise", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.smart_replenishment_advise", "subForm", 1, EsAliasEnum.SUB_FORM.getMax()),

    /**
     * 阶段推进器衍生字段 初次阶段进入时间 该字段存入数据库的是常规的date时间戳 前端展示值是停留时长： now - 时间戳
     */
    FIRST_INTO_STAGE_TIME(900100, "first_into_stage_time", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.first_into_stage_time","date", 1, EsAliasEnum.DATE.getMax()),

    /**
     * 阶段推进器衍生字段 当前阶段进入时间 该字段存入数据库的是常规的date时间戳 前端展示值是停留时长 now - 时间戳
     */
    NOW_INTO_STAGE_TIME(900101, "now_into_stage_time", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.now_into_stage_time","date", 1, EsAliasEnum.DATE.getMax()),

    /**
     * 工作报告阅读状态
     */
    WORKREPORT_READ_STATUS(910000, "readStatus", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.read_status", "text", 1, 1),

    /**
     * 知识库衍生字段，拓展问法
     */
    KNOWLEDGE_EXPAND_CONSULT(920000, "expandConsult", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.expand_consult","text", 1, 1),

    /**
     * 知识库衍生字段，关键词
     */
    KNOWLEDGE_KEYWORDS(920001, "keywords", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.keywords","text", 1, 1),

    /**
     * 知识库衍生字段，建议回复
     */
    KNOWLEDGE_CONTENT(920002, "content", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.content", "text", 1, 1),
    /**
     * 所属分组
     */
    PUBLIC_GROUP(930000, "public_Group", BelongEnum.SAAS.getAlias(), "enum.fieldType.description.public_group", "text", 1, 1),


    NODE_ID(940000, "node_id", BelongEnum.SYSTEM.getAlias(), "enum.fieldType.description.node_id", "text", 1, 1),
    ;

    /**
     * 字段类型
     */
    private Integer type;

    /**
     * 字段类型英文，ConditionServiceImpl#list用于反射查找对应的字段类型
     */
    private String alias;

    /**
     * 字段所属   basic   complex  system   saas:saas独有字段，暂时不显示在左侧控件框
     */
    private String belong;

    /**
     * 字段描述
     */
    private String description;

    /**
     * es索引前缀
     */
    private String esalias;

    /**
     * 索引最小值
     */
    private Integer min;

    /**
     * 索引最大值
     */
    private Integer max;

    FieldTypeEnum(Integer type, String alias, String belong, String description, String esalias, Integer min, Integer max) {
        this.type = type;
        this.alias = alias;
        this.belong = belong;
        this.description = description;
        this.esalias = esalias;
        this.min = min;
        this.max = max;
    }

    public static FieldTypeEnum getFieldTypeEnum(Integer type) {
        for (FieldTypeEnum e : values()) {
            if (e.getType().equals(type)) {
                return e;
            }
        }
        return null;
    }

    public static FieldTypeEnum getFieldTypeEnumByAliasLowerCase(String alias) {
        for (FieldTypeEnum e : values()) {
            if (alias.equals(e.getAlias().toLowerCase())) {
                return e;
            }
        }
        return null;
    }

    /**
     * 根据类型进行分类返回
     *
     * @return 根据搜索和统计分为三种类型
     */
    public static FieldTypeClassifyClass esaliasTypeList() {
        FieldTypeClassifyClass fieldTypeClassifyClass = new FieldTypeClassifyClass();
        //数字型的code集合
        List<Integer> numIdList = new ArrayList<>();
        List<FieldTypeEnum> numList = new ArrayList<>();
        //非搜索型的code集合（文件，连接）
        List<Integer> noSearchIdList = new ArrayList<>();
        List<FieldTypeEnum> noSearchList = new ArrayList<>();
        //可筛选的集合
        List<Integer> selectIdList = new ArrayList<>();
        List<FieldTypeEnum> selectList = new ArrayList<>();
        //人员归属的集合
        List<Integer> belongIdList = new ArrayList<>();
        List<FieldTypeEnum> belongList = new ArrayList<>();
        //时间类型的集合
        List<Integer> timeIdList = new ArrayList<>();
        List<FieldTypeEnum> timeList = new ArrayList<>();
        //地址类型的集合
        List<Integer> addressIdList = new ArrayList<>();
        List<FieldTypeEnum> addressList = new ArrayList<>();
        //漏斗维度的集合
        List<Integer> funnelIdList = new ArrayList<>();
        List<FieldTypeEnum> funnelList = new ArrayList<>();

        for (FieldTypeEnum e : values()) {
            String esalias = e.getEsalias();
            Integer type = e.getType();
            if ("other".equals(esalias) || "geo".equals(esalias)) {
                noSearchIdList.add(type);
                noSearchList.add(e);
            } else {
                //阶段比例本质也为数字字段
                boolean flag = numField(e, esalias);
                if (flag) {
                    numIdList.add(type);
                    numList.add(e);
                } else if ("date".equals(esalias)) {
                    timeIdList.add(type);
                    timeList.add(e);
                }
                selectIdList.add(type);
                selectList.add(e);
            }
        }
        belongList.add(CREATORID);
        belongList.add(OWNERID);
        belongList.add(COUSERID);
        belongList.add(USER);
        belongList.add(USER_GROUP);
        for (FieldTypeEnum fieldTypeEnum : belongList) {
            belongIdList.add(fieldTypeEnum.getType());
        }
        addressList.add(ADDRESS);
        addressIdList.add(ADDRESS.getType());
        funnelList.add(COMBO);
        funnelList.add(RADIO_GROUP);
        funnelList.add(USER);
        funnelList.add(DEPT);
        funnelList.add(STAGE_THRUSTER);
/*        funnelList.add(CHECKBOX_GROUP);
        funnelList.add(COMBO_CHECK);
        funnelList.add(CHECK_COMBO);*/
        funnelIdList.add(COMBO.getType());
        funnelIdList.add(RADIO_GROUP.getType());
        funnelIdList.add(USER.getType());
        funnelIdList.add(DEPT.getType());
        funnelIdList.add(STAGE_THRUSTER.getType());
//        funnelIdList.add(CHECKBOX_GROUP.getType());
//        funnelIdList.add(COMBO_CHECK.getType());
//        funnelIdList.add(CHECK_COMBO.getType());
        fieldTypeClassifyClass.setNoSearchIdList(noSearchIdList);
        fieldTypeClassifyClass.setNoSearchList(noSearchList);
        fieldTypeClassifyClass.setSelectIdList(selectIdList);
        fieldTypeClassifyClass.setSelectList(selectList);
        fieldTypeClassifyClass.setNumIdList(numIdList);
        fieldTypeClassifyClass.setNumList(numList);
        fieldTypeClassifyClass.setTimeIdList(timeIdList);
        fieldTypeClassifyClass.setTimeList(timeList);
        fieldTypeClassifyClass.setBelongIdList(belongIdList);
        fieldTypeClassifyClass.setBelongList(belongList);
        fieldTypeClassifyClass.setAddressIdList(addressIdList);
        fieldTypeClassifyClass.setAddressList(addressList);
        fieldTypeClassifyClass.setFunnelIdList(funnelIdList);
        fieldTypeClassifyClass.setFunnelList(funnelList);
        return fieldTypeClassifyClass;
    }
    /**
     * 单个部门型字段
     * @return java.util.List<java.lang.Integer>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static List<Integer> depList(){
        return Arrays.asList(DEPT.type, DEPARTMENTID.type);
    }
    /**
     * 产品分类型字段
     * @return java.util.List<java.lang.Integer>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static List<Integer> categoryList(){
        return Arrays.asList(CATEGORY_ID.type);
    }

    /**
     * 需要二次解析的枚举
     * @return
     */
    public static List<Integer> getExplainFieldTypeEnumType() {
        List<Integer> list = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        list.add(RADIO_GROUP.getType());
        list.add(COMBO.getType());
        list.add(COMBO_CHECK.getType());
        return list;
    }

    /**
     * 判断是否子表单类型
     * @param type 类型参数
     * @return 是否为子表单
     */
    public static boolean isSubFormType(Integer type){
        FieldTypeEnum fieldTypeEnum = getFieldTypeEnum(type);
        String esAlias = "";
        if(fieldTypeEnum != null) {
            esAlias = fieldTypeEnum.getEsalias();
        }
        return Objects.equals(esAlias, SUB_FORM.getEsalias());
    }

    /**
     * 判断字段是否属于子表单内的字段
     * @param parentAttr 父字段的type
     * @return 是否为子表单
     */
    public static boolean isBelongSubForm(String parentAttr){
        if(StringUtils.isEmpty(parentAttr)){
            return false;
        }
        return parentAttr.contains(XbbConstant.SUB_FORM_PARENT);
    }

    /**
     * 判断是否数组类型
     * @param type 类型参数
     * @return 是否为子表单
     */
    public static boolean isArrayType(Integer type){
        FieldTypeEnum fieldTypeEnum = getFieldTypeEnum(type);
        String esAlias = "";
        if(fieldTypeEnum != null) {
            esAlias = fieldTypeEnum.getEsalias();
        }
        return Objects.equals(esAlias, CHECKBOX_GROUP.getEsalias());
    }
    /**
     * 判断是否文本类型
     * @param type 类型参数
     * @return 是否为文本
     */
    public static boolean isTextType(Integer type){
        FieldTypeEnum fieldTypeEnum = getFieldTypeEnum(type);
        String esAlias = "";
        if(fieldTypeEnum != null) {
            esAlias = fieldTypeEnum.getEsalias();
        }
        return Objects.equals(esAlias, TEXT.getEsalias());
    }

    public static boolean isArray(Integer type) {
        return isArrayType(type) || Objects.equals(FieldTypeEnum.IMAGE.getType(), type);
    }

    public static boolean isJsonObject(Integer type) {
        return Objects.equals(FieldTypeEnum.ADDRESS.getType(), type) || Objects.equals(FieldTypeEnum.LOCATION.getType(), type);
    }
    /**
     * 需要跳过的字段（记录日志时，某些字段的变更无法记录，如图片、附件等）
     * @param fieldType 被判断的字段的类型
     * @return boolean
     * @author zcp
     * @date 2019/7/2 21:39
     * @since v1.0
     * @version v1.0
     */
    public static boolean filterType(Integer fieldType){
        return fieldType == null || Objects.equals(DATAID.type, fieldType) /*|| Objects.equals(IMAGE.type, fieldType) || Objects.equals(UPLOAD.type, fieldType)*/
                || Objects.equals(VIDEO.type, fieldType) || Objects.equals(COUNT.type, fieldType) || Objects.equals(SEPARATOR.type, fieldType) || Objects.equals(HREF.type, fieldType)
                || Objects.equals(LINK_QUERY.type, fieldType) || Objects.equals(CREATORID.type, fieldType) || Objects.equals(ADDTIME.type, fieldType)
                || Objects.equals(TEAM_USER.type, fieldType) || Objects.equals(TEAM_USER_TYPE.type, fieldType) || Objects.equals(SELECT_PRODUCT.type, fieldType) || Objects.equals(CHECK_COMBO.type, fieldType)
                || Objects.equals(LINK_FORM.type, fieldType) || Objects.equals(WORK_ORDER_TIME_OUT.type, fieldType) || Objects.equals(WORK_ORDER_ROB.type, fieldType)
                || Objects.equals(WORK_ORDER_DATA_TIME_OUT.type, fieldType) || Objects.equals(WORK_ORDER_DATA_TIME_NOT_OUT.type, fieldType) || Objects.equals(WORK_ORDER_STATUS.type, fieldType) || Objects.equals(WORK_ORDER_STAGE.type, fieldType)
                || Objects.equals(WORK_ORDER_ALL_OUTBOUND.type, fieldType) || Objects.equals(WORK_ORDER_NODE_STATUS.type, fieldType) || Objects.equals(TEMPLATE.type, fieldType)
                || Objects.equals(OPTION.type, fieldType) || Objects.equals(FOCUS.type, fieldType) || Objects.equals(REMIND.type, fieldType) || Objects.equals(CALL.type, fieldType) || Objects.equals(FLOW.type, fieldType)
                || Objects.equals(CONTRACT.type, fieldType) || Objects.equals(PRODUCT.type, fieldType) || Objects.equals(STOCK_SEARCH.type, fieldType) || Objects.equals(WAIT_INSTOCK_CONTRACT.type, fieldType)
                || Objects.equals(WAIT_OUTSTOCK_PRODUCT.type, fieldType) || Objects.equals(HEAD_RADIO_GROUP.type, fieldType) || Objects.equals(HEAD_CHECKBOX_GROUP.type, fieldType) || Objects.equals(STOCK_WAREHOUSE_ID.type, fieldType)
                || Objects.equals(WAREHOUSE_CHECKED.type, fieldType) || Objects.equals(WAREHOUSE_IS_NOTIFY.type, fieldType) || Objects.equals(ALL_WAREHOUSE_ALL_LIMIT.type, fieldType) || Objects.equals(ALL_WAREHOUSE_UPPER_LIMIT.type, fieldType)
                || Objects.equals(ALL_WAREHOUSE_LOWER_LIMIT.type, fieldType) || Objects.equals(CHECKED_WAREHOUSE_ALL_LIMIT.type, fieldType) || Objects.equals(CHECKED_WAREHOUSE_UPPER_LIMIT.type, fieldType) || Objects.equals(CHECKED_WAREHOUSE_LOWER_LIMIT.type, fieldType)
                || Objects.equals(BATCH_WAREHOUSE_ID.type, fieldType) || Objects.equals(BATCH_WAREHOUSE_CHECKED.type, fieldType);
    }

    public String getDescription() {
        return I18nMessageUtil.getMessage(description);
    }

    /**
     * 高级版可用字段
     * @return
     */
    public static List<Integer> getComplexList() {
        return Arrays.asList(FieldTypeEnum.SUB_FORM.getType(), FieldTypeEnum.LINK_DATA.getType(), FieldTypeEnum.LINK_DATA_MULTI.getType(), FieldTypeEnum.USER.getType(), FieldTypeEnum.USER_GROUP.getType(), FieldTypeEnum.DEPT.getType(),
                FieldTypeEnum.DEPT_GROUP.getType(), FieldTypeEnum.MANUAL_SIGN.getType(), FieldTypeEnum.RICH_TEXT.getType());
    }

    /**
     * 旗舰版所有可用字段，包含高级版
     * @return
     */
    public static List<Integer> getUltimateList() {
        List<Integer> list = new ArrayList<>(getComplexList());
        List<Integer> ultimateList = new ArrayList<>(getUltimatePrivateList());
        list.addAll(ultimateList);
        return list;
    }

    /**
     * 旗舰版可用字段，不含用高级版的字段
     * @return
     */
    public static List<Integer> getUltimatePrivateList() {
       return Arrays.asList(FieldTypeEnum.STAGE_THRUSTER.getType());
    }

    /**
     * 支持设置计算公式的字段（整体）
     *
     * @return java.util.List<java.lang.Integer>
     * @author zyy
     * @date 2023/3/1
     * @version v1.0
     */
    public static List<Integer> getComputedType(){
        List<Integer> supportComputeFieldType = new ArrayList<>();
        //数字
        supportComputeFieldType.addAll(getNumComputedType());
        //日期
        supportComputeFieldType.addAll(getDateComputedType());
        //其它
        supportComputeFieldType.addAll(getOtherComputedType());
        return supportComputeFieldType;
    }

    /**
     * 支持设置计算公式的数字字段
     *
     * @return java.util.List<java.lang.Integer>
     * @author zyy
     * @date 2023/3/1
     * @version v1.0
     */
    public static List<Integer> getNumComputedType(){
        return Arrays.asList(FieldTypeEnum.NUM.getType(), FieldTypeEnum.STAGE_RATIO.getType());
    }
    /**
     * 支持设置计算公式的日期字段
     *
     * @return java.util.List<java.lang.Integer>
     * @author zyy
     * @date 2023/3/1
     * @version v1.0
     */
    public static List<Integer> getDateComputedType(){
        return Arrays.asList(FieldTypeEnum.ADDTIME.getType(), FieldTypeEnum.UPDATETIME.getType(), FieldTypeEnum.CLOSETIME.getType(), FieldTypeEnum.ENDTIME.getType(), FieldTypeEnum.DATETIME.getType(),
                FieldTypeEnum.STOCK_FLOW_SHEET_DATE.getType());
    }
    /**
     * 支持设置计算公式的其它字段
     *
     * @return java.util.List<java.lang.Integer>
     * @author zyy
     * @date 2023/3/1
     * @version v1.0
     */
    public static List<Integer> getOtherComputedType(){
        return Arrays.asList(FieldTypeEnum.TEXT.getType(),FieldTypeEnum.USER.getType(),FieldTypeEnum.CREATORID.getType(),FieldTypeEnum.DEPT.getType(),
                FieldTypeEnum.SERIALNO.getType(),FieldTypeEnum.OWNERID.getType(),FieldTypeEnum.COMBO.getType(),FieldTypeEnum.RADIO_GROUP.getType(),
                FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(),FieldTypeEnum.LINK_BUSINESS_MULTI.getType());
    }

    public static List<String> getDateSpecialAlias(){
        return Arrays.asList(FieldTypeEnum.ADDTIME.getAlias(), FieldTypeEnum.UPDATETIME.getAlias(), FieldTypeEnum.CLOSETIME.getAlias(), FieldTypeEnum.ENDTIME.getAlias(),
                FieldTypeEnum.STOCK_FLOW_SHEET_DATE.getAlias());
    }


    public static List<Integer> getUserList() {
        return Arrays.asList(FieldTypeEnum.USER.getType(), FieldTypeEnum.USER_GROUP.getType(), FieldTypeEnum.OWNERID.getType(), FieldTypeEnum.COUSERID.getType(), FieldTypeEnum.CREATORID.getType());
    }

    public static List<Integer> getDeptList() {
        return Arrays.asList( FieldTypeEnum.DEPT.getType(), FieldTypeEnum.DEPT_GROUP.getType(), FieldTypeEnum.DEPARTMENTID.getType(), FieldTypeEnum.CREATOR_DEPT.getType());
    }

    public static List<Integer> getFieldDependenceType() {
        return Arrays.asList(COMBO.getType(), COMBO_CHECK.getType(), RADIO_GROUP.getType(), CHECKBOX_GROUP.getType());
    }

    /**
     * 负责人、协同人
     * @return java.util.List<java.lang.Integer>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static List<Integer> getTeamList() {
        return Arrays.asList(FieldTypeEnum.OWNERID.getType(), FieldTypeEnum.COUSERID.getType());
    }
    /**
     * 判断字段类似是否是数字类型
     * num、阶段比例类型都为数字
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean numFieldType(Integer fieldType){
        return Objects.equals(NUM.type, fieldType) || Objects.equals(STAGE_RATIO.type, fieldType);
    }

    /**
     * 判断字段类似是否是数字类型
     * num、阶段比例类型都为数字
     * @param fieldTypeEnum
     * @param esalias
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    private static boolean numField(FieldTypeEnum fieldTypeEnum, String esalias) {
        return ("num".equals(esalias) && Objects.equals(NUM, fieldTypeEnum)) || ("long".equals(esalias) && Objects.equals(STAGE_RATIO, fieldTypeEnum));
    }
    /**
     * 覆盖导入中无需更新的字段
     * @return
     */
    public static List<Integer> getUnnecessaryFieldType() {
        return Arrays.asList(FieldTypeEnum.IMAGE.getType(), FieldTypeEnum.UPLOAD.getType(), FieldTypeEnum.MEMO.getType(), FieldTypeEnum.VIDEO.getType(), FieldTypeEnum.LINK_QUERY.getType(), FieldTypeEnum.LOCATION.getType(), FieldTypeEnum.RICH_TEXT_EDITOR.getType(), FieldTypeEnum.STAGE_THRUSTER.getType(), FieldTypeEnum.FIRST_INTO_STAGE_TIME.getType(), FieldTypeEnum.NOW_INTO_STAGE_TIME.getType());

    }


    public static boolean isCombox4Funnel(Integer fieldType) {
        return CHECKBOX_GROUP.getType().equals(fieldType) || COMBO_CHECK.getType().equals(fieldType) || CHECK_COMBO.getType().equals(fieldType);
    }

    /**
     * 判断是否为时间类型
     * @param fieldType 字段类型
     * @author zhouwq
     * @date 2019/5/22 10:11
     * @return true为时间类型
     */
    public static boolean isDateTimeByFieldType(Integer fieldType) {
        boolean flag = false;
        FieldTypeEnum fieldTypeEnum = getFieldTypeEnum(fieldType);
        if (fieldTypeEnum != null) {
            switch (fieldTypeEnum) {
                case DATETIME:
                case ADDTIME:
                case UPDATETIME:
                case CLOSETIME:
                case ENDTIME:
                    flag = true;
                    break;
                default:
                    break;
            }
        }
        return flag;
    }

    /**
     * 判断是否是筛选条件，表头字段要过滤的字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean showAbleFilter(Integer fieldType) {
        return baseFilter(fieldType)
                || Objects.equals(fieldType, IMAGE.getType())
                || Objects.equals(fieldType, UPLOAD.getType())
                || Objects.equals(fieldType, FieldTypeEnum.LABEL.getType())
                || Objects.equals(fieldType, COMBO_LINK_BUSINESS.getType());
    }
    /**
     * 判断是否是数据集数据源节点要过滤的字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean showAbleFilter4DataSet(Integer fieldType) {
        return baseFilter(fieldType)
                || Objects.equals(fieldType, LINK_DATA.getType())
                || Objects.equals(fieldType, IMAGE.getType())
                || Objects.equals(fieldType, UPLOAD.getType())
                || Objects.equals(fieldType, COMBO_LINK_BUSINESS.getType())
                || Objects.equals(fieldType, RICH_TEXT.getType())
                || Objects.equals(fieldType, LINK_DATA_MULTI.getType())
                ;
    }

    /**
     * 判断是否是筛选条件，表头字段要过滤的字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean selectAbleFilter(Integer fieldType) {
        return showAbleFilter4DataSet(fieldType)
                || Objects.equals(fieldType, ID.getType())
                || Objects.equals(fieldType, DATAID.getType())
                ;
    }

    /**
     * 判断是否是合并节点字段【要过滤】的字段类型
     * @param fieldType
     * @return boolean true代表过滤
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean unionAbleFilter(Integer fieldType) {
        boolean filter = linkAbleFilter(fieldType)
                || Objects.equals(fieldType, COMBO.type)
                || Objects.equals(fieldType, COMBO_NUM.type)
                || Objects.equals(fieldType, CHECKBOX_GROUP.type)
                || Objects.equals(fieldType, RADIO_GROUP.type)
                || Objects.equals(fieldType, COMBO_CHECK.type)
                || Objects.equals(fieldType, CHECK_COMBO.type)
                || Objects.equals(fieldType, COMBO_LINK_BUSINESS.type)
                || Objects.equals(fieldType, LABEL.type)
                || Objects.equals(fieldType, STAGE_THRUSTER.type)
                ;
        //负责人、协同人允许合并，不过滤
        boolean nonFilter = Objects.equals(fieldType, OWNERID.type)
                || Objects.equals(fieldType, COUSERID.type)
                //备注、多行文本不允许连接，但是允许合并
                || Objects.equals(fieldType, MEMO.type)
                || Objects.equals(fieldType, TEXTAREA.type)
                ;
        return filter && !nonFilter;
    }

    /**
     * 判断是否是连接节点【要过滤】的字段类型
     * 数据集专用
     * @param fieldType
     * @return boolean true代表过滤
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean joinAbleFilter(Integer fieldType) {
        return linkAbleFilter(fieldType)
                || Objects.equals(fieldType, OWNERID.getType())
                || Objects.equals(fieldType, COUSERID.getType())
                || Objects.equals(fieldType, COMBO_LINK_BUSINESS.type)
                ;
    }

    /**
     * 排除不能关联的项目
     * BI内使用
     * @param fieldType
     * @return
     * @update 2022.6.2 从chartServiceImpl内移入，未动逻辑 - 只对原有零散代码做归类汇总
     */
    public static boolean linkAbleFilter(Integer fieldType) {
        return baseFilter4GroupLink(fieldType)
                || FieldTypeEnum.MEMO.getType().equals(fieldType)
                || FieldTypeEnum.TEXTAREA.getType().equals(fieldType)
                || FieldTypeEnum.USER_GROUP.getType().equals(fieldType)
                || FieldTypeEnum.DEPT_GROUP.getType().equals(fieldType)
                || FieldTypeEnum.TEAM_USER.getType().equals(fieldType)
                || FieldTypeEnum.TEAM_USER_TYPE.getType().equals(fieldType)
                || FieldTypeEnum.ADDRESS.getType().equals(fieldType)
//                || FieldTypeEnum.LINK_BUSINESS_SINGLE.getType().equals(fieldType)
                || FieldTypeEnum.LINK_BUSINESS_MULTI.getType().equals(fieldType)
                || FieldTypeEnum.CHECKBOX_GROUP.getType().equals(fieldType)
                || FieldTypeEnum.CONTACT_NUMBER.getType().equals(fieldType)
                || FieldTypeEnum.DEPARTMENTID.getType().equals(fieldType)
                || FieldTypeEnum.COUSERID.getType().equals(fieldType)
                || FieldTypeEnum.COMBO_CHECK.getType().equals(fieldType)
                || FieldTypeEnum.SWITCH.getType().equals(fieldType)
                //下拉的也禁止关联及连接
                || COMBO.type.equals(fieldType)
                || RADIO_GROUP.type.equals(fieldType)
                || STAGE_THRUSTER.type.equals(fieldType)
                ;
    }

    /**
     * 判断是否是分组字段要过滤的字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean groupAbleFilter(Integer fieldType) {
        return baseFilter4GroupLink(fieldType)
                //下拉+关联业务选择，比如跟进记录的跟进业务 不允许分组但是要允许连接
                || Objects.equals(fieldType, COMBO_LINK_BUSINESS.getType())
                ;
    }
    /**
     * 分组、连接的基础过滤字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    private static boolean baseFilter4GroupLink(Integer fieldType) {
        return baseFilter(fieldType)
                || isSubFormType(fieldType) || isArrayType(fieldType)
                || Objects.equals(fieldType, LINK_DATA.getType())
                || Objects.equals(fieldType, RICH_TEXT.getType())
                || Objects.equals(fieldType,MANUAL_SIGN.getType())
                || Objects.equals(fieldType, LINK_DATA_MULTI.getType())
                || Objects.equals(fieldType, IMAGE.getType())
                || Objects.equals(fieldType, UPLOAD.getType())
                || Objects.equals(fieldType, COUSERID.getType())
                ;
    }
    /**
     * 判断是否是汇总字段要过滤的字段类型
     * @param fieldType
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static boolean summaryAbleFilter(Integer fieldType) {
        List<Integer> noSearchIdList = esaliasTypeList().getNoSearchIdList();
        List<Integer> numIdList = esaliasTypeList().getNumIdList();
        return showAbleFilter(fieldType)
                || noSearchIdList.contains(fieldType)
                || numIdList.contains(fieldType);
    }

    /**
     * 根据字段类型判断字段是否过滤
     * 基础筛选
     * @param fieldType 字段类型
     * @return true过滤 false不过滤
     * @update 2022.6.2 从chartServiceImpl内移入，未动逻辑
     */
    public static boolean baseFilter(Integer fieldType) {
        return FieldTypeEnum.SELECT_PRODUCT.getType().equals(fieldType) ||
                FieldTypeEnum.LOCATION.getType().equals(fieldType) || FieldTypeEnum.UPLOAD.getType().equals(fieldType) ||
                FieldTypeEnum.HREF.getType().equals(fieldType) ||
                FieldTypeEnum.VIDEO.getType().equals(fieldType)
                || FieldTypeEnum.SEPARATOR.getType().equals(fieldType) || FieldTypeEnum.LINK_QUERY.getType().equals(fieldType)
                //以下操作类型的有可能不需要
                || FieldTypeEnum.SPECIFICATION.getType().equals(fieldType)
                || FieldTypeEnum.OPTION.getType().equals(fieldType)
                || FieldTypeEnum.FOCUS.getType().equals(fieldType) || FieldTypeEnum.REMIND.getType().equals(fieldType)
                || FieldTypeEnum.CALL.getType().equals(fieldType) || FieldTypeEnum.FLOW.getType().equals(fieldType)
                || FieldTypeEnum.CONTRACT.getType().equals(fieldType) || FieldTypeEnum.PRODUCT.getType().equals(fieldType)
                || FieldTypeEnum.STOCK_SEARCH.getType().equals(fieldType) || FieldTypeEnum.WAIT_INSTOCK_CONTRACT.getType().equals(fieldType)
                || FieldTypeEnum.WAIT_OUTSTOCK_PRODUCT.getType().equals(fieldType) || FieldTypeEnum.HEAD_RADIO_GROUP.getType().equals(fieldType)
                || FieldTypeEnum.HEAD_CHECKBOX_GROUP.getType().equals(fieldType)
                || FieldTypeEnum.MEMO.getType().equals(fieldType)
                || FieldTypeEnum.MANUAL_SIGN.getType().equals(fieldType)
                || Objects.equals(fieldType, RICH_TEXT.getType())
                || Objects.equals(fieldType, ACCOUNT_PERIOD.getType())
                || FieldTypeEnum.TEMPLATE_FIELD.getType().equals(fieldType)
                ;
    }

    /**
     * 判断是否满足下拉框排序
     * @param fieldType 字段类型
     * @author zhouwq
     * @date 2019/5/22 10:11
     * @return true为时间类型
     */
    public static boolean isReOrder4Combo(Integer fieldType) {
        return Objects.equals(FieldTypeEnum.COMBO.getType(),fieldType)
                //阶段推进器在用户的使用体验上跟下拉框类型的字段是相同的，产品要求该字段类型也要走排序
                || Objects.equals(FieldTypeEnum.STAGE_THRUSTER.getType(),fieldType);
    }
}
